<?php




$userid = $_SESSION['user_id'];


  
        //form is submitted an we want to change description of company
        $a = $CP_controller->findCforEdit($userid);
            for($i=0;$i<count($a);$i++){
               if(isset($_POST['submitc'.$i.''])){
               if($a[$i]==true){
                   $name = $a[$i]->name;
                   $companyid = $a[$i]->id;
                   $desc = $_POST[''.$name.''];
                   $CP_controller->changeCompanyDesc($companyid,$desc);


                }
            }
    }
$a = $CP_controller->findCforEdit($userid);
?>
<div id="companyedit">
    

<?php

for($i=0;$i<count($a);$i++){
    
   if($a[$i]==true){
    $name = $a[$i]->name;
    $desc = $a[$i]->description;
  echo  ('<form method="post" id="companychange'.$i.'">');
echo "<h3>$name</h3>";
echo ('<label>Beskrivelse av Bedrift</label><textarea name="'.$name.'" rows="5" cols="50">'.$desc.'</textarea></br>');
echo ('<input type="submit" name="submitc'.$i.'" value="Endre" /> ');
echo ('</form>');

   }
}



?>
    
    
    
    
</div>